<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">

<meta charset="utf-8" />
<title></title>

<meta name="description" content="overview & stats" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/bootstrap-responsive.min.css" rel="stylesheet" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
<!--[if IE 7]><link rel="stylesheet" href="css/font-awesome-ie7.min.css" /><![endif]-->
<!--[if lt IE 9]><link rel="stylesheet" href="css/ace-ie.min.css" /><![endif]-->
<!-- 下拉框 -->
<link rel="stylesheet" href="css/chosen.css" />

<link rel="stylesheet" href="css/ace.min.css" />
<link rel="stylesheet" href="css/ace-responsive.min.css" />
<link rel="stylesheet" href="css/ace-skins.min.css" />

<link rel="stylesheet" href="css/datepicker.css" />
<!-- 日期框 -->
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="js/jquery.tips.js"></script>

<script type="text/javascript">
	//保存
	function save() {
		if ($("#USERID").val() == "") {
			$("#USERID").tips({
				side : 3,
				msg : '请输入用户id',
				bg : '#AE81FF',
				time : 2
			});
			$("#USERID").focus();
			return false;
		}
		if ($("#LOGINNAME").val() == "") {
			$("#LOGINNAME").tips({
				side : 3,
				msg : '请输入登录名',
				bg : '#AE81FF',
				time : 2
			});
			$("#LOGINNAME").focus();
			return false;
		}
		if ($("#PASSWORD").val() == "") {
			$("#PASSWORD").tips({
				side : 3,
				msg : '请输入密码',
				bg : '#AE81FF',
				time : 2
			});
			$("#PASSWORD").focus();
			return false;
		}
		if($("#PASSWORD").val()!=$("#pwdchk").val()){
			
			$("#pwdchk").tips({
				side:3,
	            msg:'两次密码不相同',
	            bg:'#AE81FF',
	            time:3
	        });
			
			$("#pwdchk").focus();
			return false;
		}
		if ($("#NICKNAME").val() == "") {
			$("#NICKNAME").tips({
				side : 3,
				msg : '请输入昵称',
				bg : '#AE81FF',
				time : 2
			});
			$("#NICKNAME").focus();
			return false;
		}
		if ($("#PORTRAIT").val() == "") {
			$("#PORTRAIT").tips({
				side : 3,
				msg : '请输入头像',
				bg : '#AE81FF',
				time : 2
			});
			$("#PORTRAIT").focus();
			return false;
		}
		if ($("#BIRTHDAY").val() == "") {
			$("#BIRTHDAY").tips({
				side : 3,
				msg : '请输入生日',
				bg : '#AE81FF',
				time : 2
			});
			$("#BIRTHDAY").focus();
			return false;
		}
		if ($("#SEX").val() == "") {
			$("#SEX").tips({
				side : 3,
				msg : '请输入性别',
				bg : '#AE81FF',
				time : 2
			});
			$("#SEX").focus();
			return false;
		}
		if ($("#POSITION").val() == "") {
			$("#POSITION").tips({
				side : 3,
				msg : '请输入地址',
				bg : '#AE81FF',
				time : 2
			});
			$("#POSITION").focus();
			return false;
		}
		if ($("#MAIL").val() == "") {
			$("#MAIL").tips({
				side : 3,
				msg : '请输入邮箱',
				bg : '#AE81FF',
				time : 2
			});
			$("#MAIL").focus();
			return false;
		}
		if ($("#TELEPHONE").val() == "") {
			$("#TELEPHONE").tips({
				side : 3,
				msg : '请输入电话',
				bg : '#AE81FF',
				time : 2
			});
			$("#TELEPHONE").focus();
			return false;
		}
		$("#Form").submit();
		$("#zhongxin").hide();
		$("#zhongxin2").show();
	}
</script>
</head>
<body>
	<div class="span6">
		<div class="widget-box transparent">
			<div class="widget">
				<div class="widget-toolbar no-border">
					<ul class="nav nav-tabs" id="recent-tab">
						<li class="active"><a data-toggle="tab" href="#task-tab">信息</a></li>
						<li><a data-toggle="tab" href="#member-tab">权限</a></li>
					</ul>
				</div>
			</div>

			<div class="widget-body">
				<div class="widget-main padding-5">
					<form action="common/${msg }.do" name="Form" id="Form" method="post">
					<div id="zhongxin">
						<div class="tab-content padding-8">
							<div id="task-tab" class="tab-pane active">
								<input type="hidden" name="COMMON_ID" id="COMMON_ID" value="${pd.COMMON_ID}" />
									<table>
										<tr>
											<td><input type="text" name="USERID" id="USERID"
												value="${pd.USERID}" maxlength="32" placeholder="这里输入用户id"
												title="用户id" /></td>
											<td><input type="text" name="LOGINNAME" id="LOGINNAME"
												value="${pd.LOGINNAME}" maxlength="32" placeholder="这里输入登录名"
												title="登录名" /></td>
										</tr>
										<tr>
											<td><input type="text" name="PASSWORD" id="PASSWORD"
												maxlength="32" placeholder="这里输入密码"
												title="密码" /></td>
											<td><input type="text" name="pwdchk" id="pwdchk"
												maxlength="32" placeholder="这里输入密码"
												title="密码" /></td>
										</tr>
										<tr>
											<td><input type="text" name="NICKNAME" id="NICKNAME"
												value="${pd.NICKNAME}" maxlength="32" placeholder="这里输入昵称"
												title="昵称" /></td>
											<td><input type="text" name="PORTRAIT" id="PORTRAIT"
												value="${pd.PORTRAIT}" maxlength="32" placeholder="这里输入头像"
												title="头像" /></td>
										</tr>
										<tr>
											<td><input class="span10 date-picker" name="BIRTHDAY"
												id="BIRTHDAY" value="${pd.BIRTHDAY}" type="text"
												data-date-format="yyyy-mm-dd" readonly="readonly"
												placeholder="生日" title="生日" /></td>
											<td><input type="number" name="SEX" id="SEX"
												value="${pd.SEX}" maxlength="32" placeholder="这里输入性别"
												title="性别" /></td>
										</tr>
										<tr>
											<td><input type="text" name="POSITION" id="POSITION"
												value="${pd.POSITION}" maxlength="32" placeholder="这里输入地址"
												title="地址" /></td>
											<td><input type="text" name="MAIL" id="MAIL"
												value="${pd.MAIL}" maxlength="32" placeholder="这里输入邮箱"
												title="邮箱" /></td>
										</tr>
										<tr>
											<td><input type="text" name="TELEPHONE" id="TELEPHONE"
												value="${pd.TELEPHONE}" maxlength="32" placeholder="这里输入电话"
												title="电话" /></td>
											<td>
												<input type="text" name="MONEY" id="MONEY" value="${pd.MONEY}" maxlength="32" placeholder="这里输入余额" title="余额" />
											</td>
										</tr>
										<tr>
											<td colspan="2" style="text-align: center;">
												<a class="btn btn-mini btn-primary" onclick="save();">保存</a> 
												<a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
											</td>
										</tr>
									</table>
							</div>

							<div id="member-tab" class="tab-pane">
								<span class="span5"> <label class="pull inline">
									<small class="muted">允许登陆:</small>
									<c:choose>
										<c:when test="${pd.LOGIN==1}">
											<input name="LOGIN" value="${pd.LOGIN}" type="checkbox" class="ace ace-switch ace-switch-5" />
										</c:when>
										<c:otherwise>
											<input name="LOGIN" value="${pd.LOGIN}" checked="checked" type="checkbox" class="ace ace-switch ace-switch-5" />
										</c:otherwise>
									</c:choose> <span class="lbl"></span>
								</label>
								</span> <span class="span5"> <label class="pull inline">
										<small class="muted">允许进入直播间:</small> 
										<c:choose>
											<c:when test="${pd.LOGINMOVE==1}">
												<input name="LOGINMOVE" value="${pd.LOGINMOVE}" type="checkbox" class="ace ace-switch ace-switch-5" />
											</c:when>
											<c:otherwise>
												<input name="LOGINMOVE" value="${pd.LOGINMOVE}" checked="checked" type="checkbox" class="ace ace-switch ace-switch-5" />
											</c:otherwise>
										</c:choose> 
										<span class="lbl"></span>
								</label>
								</span> <span class="span5"> <label class="pull inline">
										<small class="muted">允许回复/评论:</small> 
										<c:choose>
											<c:when test="${pd.MESSAGE==1}">
												<input name="MESSAGE" value="${pd.MESSAGE}" type="checkbox" class="ace ace-switch ace-switch-5" />
											</c:when>
											<c:otherwise>
												<input name="MESSAGE" value="${pd.MESSAGE}" checked="checked" type="checkbox" class="ace ace-switch ace-switch-5" />
											</c:otherwise>
										</c:choose> 
										<span class="lbl"></span>
								</label>
								</span> <span class="span5"> <label class="pull inline">
										<small class="muted">允许发布任务:</small> 
										<c:choose>
											<c:when test="${pd.ISSUE==1}">
												<input name="ISSUE" value="${pd.ISSUE}" type="checkbox" class="ace ace-switch ace-switch-5" />
											</c:when>
											<c:otherwise>
												<input name="ISSUE" value="${pd.ISSUE}" checked="checked" type="checkbox" class="ace ace-switch ace-switch-5" />
											</c:otherwise>
										</c:choose> 
										<span class="lbl"></span>
								</label>
								</span>
							</div>
							<!-- member-tab -->
						</div>
						</div>
						<div id="zhongxin2" class="center" style="display: none">
							<br />
							<br />
							<br />
							<br />
							<br />
							<img src="images/jiazai.gif" /><br />
							<h4 class="lighter block green">提交中...</h4>
						</div>
					</form>
				</div>
				<!--/widget-main-->
			</div>
			<!--/widget-body-->

		</div>
		<!--/widget-box-->
	</div>
	<!-- 引入 -->
	<script type="text/javascript">
		window.jQuery|| document.write("<script src='js/jquery-1.9.1.min.js'>\x3C/script>");
	</script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/ace-elements.min.js"></script>
	<script src="js/ace.min.js"></script>
	<script type="text/javascript" src="js/chosen.jquery.min.js"></script>
	<!-- 下拉框 -->
	<script type="text/javascript" src="js/bootstrap-datepicker.min.js"></script>
	<!-- 日期框 -->
	<script type="text/javascript">
		$(window.parent.hangge());
		$(function() {
			//单选框
			$(".chzn-select").chosen();
			$(".chzn-select-deselect").chosen({
				allow_single_deselect : true
			});

			//日期框
			$('.date-picker').datepicker();
	
			//初始化编辑框
			if('${msg }' == "save" ){
				$("#member-tab").hide();
				$("li a[href='#member-tab']").hide();
			}
			
			//权限按钮点击
			$("input[type='checkbox']").click(function() {
				var str = $("#Form").serializeArray();
				
				var arr = ['LOGIN','LOGINMOVE','MESSAGE','ISSUE'];
				for(var i=0;i<arr.length;i++){
					if($("input[name='"+arr[i]+"']").attr("checked") == "checked"){
						$("input[name='"+arr[i]+"']").val("0");
					}
				}
				
				var data = "";
				var j = 0;
				while (typeof (str[j]) != "undefined") {
					data = str[j].name + "=" + str[j].value + "&" + data;
					j++;
				}
				data = "?" + data.substring(0,data.length-1);
				$.ajax({
					type : "POST",
					url : "/THDLOAN/common/edit.do"+data,
					dataType : "json",
					success : function(data) {

					}
				});
			});
		});
		
	</script>
</body>
</html>